	.text

/* Switch from current_thread to next_thread. Make next_thread
 * the current_thread, and set next_thread to 0.
 * Use eax as a temporary register; it is caller saved.
 */
	.globl thread_switch
thread_switch:
	/* YOUR CODE HERE */

    //保存当前线程寄存器信息
    pushal
    movl current_thread, %eax
    movl %esp, (%eax)           /*This saves %esp in current_thread->sp. */

    movl next_thread, %eax
    movl %eax, current_thread

    //恢复下一个线程寄存器
    movl next_thread, %eax      //获取下一个线程结构体地址
    movl (%eax), %esp           //esp为next_thread
    popal

	ret				/* pop return address from stack */
